Repository navigation
Fix the Android blur cutout sticking on the first person - #246
Merged
Merged
Conversation
ML Kit was given a bottom-up camera buffer and a reused bitmap, so STREAM_MODE kept the first mask. Flip the buffer before rotation and submit a new bitmap per frame. Co-authored-by: Cursor <cursoragent@cursor.com>
1 of 3 tasks
👋 Hi Daniel, want a second pair of eyes on this?I'm Jeffery, Stream's review agent. I look for bugs, regressions, missing tests and slow paths, and I only post findings I've checked against the code.
Or comment |
…t orientation. Remove the CPU GetPixels32 fallback, MaskFrameScale, input hashing, and the debug heartbeat. Flip the ReadPixels bytes only when the camera is not vertically mirrored, matching PublisherVideoRotator, and return the flip with the mask through Java. takeMaskIfNew now snapshots the mask size, rotation, and flip so they always describe the returned bytes. Copy the readback into a reused buffer instead of allocating per submission. Widen the compositor mask-move test bands so half-texel resampling cannot fail it. Co-authored-by: Cursor <cursoragent@cursor.com>
Brazol
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes UNI-276. On Android, the background-blur cutout stayed where the person was first detected.
The root cause is not isolated yet. On an OpenGLES3 device, the cutout tracked a live head at rotation 270 with this PR's changes applied together. At 90/270 the orientation change only adds a left/right mirror, and a per-frame bitmap on its own did not fix the problem earlier. So the fix is most likely the switch from
AsyncGPUReadbacktoReadPixels, the change of render-texture format, or both. A device A/B test will decide which changes stay.What changed (Android only,
#if UNITY_ANDROID && !UNITY_EDITOR):ReadPixelsof the small downscale target replacesAsyncGPUReadback. The copy runs only when ML Kit can accept a frame. The publish texture is never read back.R8G8B8A8_UNorm.videoVerticallyMirrored, and the mask is mapped back before upload. Previously, cameras at 0°/180° gave ML Kit an upside-down image. The rotation and flip return from Java with the mask, so a camera switch can't pair a mask with the wrong orientation.takeMaskIfNewcaptures the mask's size, rotation, and flip at the same moment it returns the bytes.Bitmapis used for each frame. The previous frame's bitmap is kept until the next frame finishes.Removed during cleanup: the CPU
GetPixels32fallback andMaskFrameScale. The fallback's trigger condition was always true, so it could switch permanently to an 8 MB-per-frame CPU path, and it never fired on device. Also removed: per-frame input hashing, the debug heartbeat, and the per-submissionGetRawTextureDataallocation.Replaces #242 (closed, not merged).
UNI-270is canceled.Test plan
RepositoryTests.When_imported_samples_expect_match_package_source_samples, caused by unrelated localAssets/Sampleschanges. The new tests cover rotations 0/90/180/270 with and without mirroring: ML Kit input matchesPublisherVideoRotator's upright image exactly, and the mask maps back onto the original camera pixels.UNITY_ANDROIDagainst the Unity 2021.3.21f1 and 6000.2.4f1 engine DLLs, with and withoutSTREAM_DEBUG_ENABLED;STREAM_LOG_BG_FILTER. 0 errors, 0 warnings.--release 8againstandroid.jar, using ML Kit stubs.ReadPixelsmain-thread cost on a low-end OpenGLES device. Not measured.